function [s,t,q,z] = reorder(s,t,q,z)

n = size(s,1);

i = 1;
while i<=n-1;
   if 1+abs(t(i,i)*s(i+1,i+1))>1+abs(s(i,i)*t(i+1,i+1));    
	  [s,t,q,z] = qzswitch(i,s,t,q,z);
      if ~(i==1);i = i-2;end
   end
   i=i+1;
end